package com.mh.rmi.server;

import com.mh.rmi.service.UserServiceImpl;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class RmiServer {

    public static void main(String[] args) {
        try {
            // 注册Registry实例，绑定端口
            Registry registry = LocateRegistry.createRegistry(9998);
            // 创建远程对象
            UserServiceImpl userService = new UserServiceImpl();
            // 将远程对象注册到RMI服务器上，即服务端注册表上
            registry.rebind("userService", userService);
            System.out.println("---RMI服务启动成功---");
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
